With the 'rightclick' attribute you can set a script file that is called when a player rightclicks a block with the item. You can use world, origin, side and player for your script.
rightclick="loader.loadScript('xyz.script');";